package com.xuecheng.content.feignclient;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 陈竞超
 * @version 1.0
 * @qq 2250537249
 */
@Component
@Slf4j
public class MediaServiceClientFallbackFactory implements FallbackFactory<MediaServiceClient> {
    //当时熔断的异常信息throwbale
    @Override
    public MediaServiceClient create(Throwable throwable) {
        return new MediaServiceClient() {
            //发生熔断，上有服务调用此方法执行降级逻辑
            @Override
            public String uploadFile(MultipartFile upload, String objectName) {
                log.debug("远程调用文件上传发生熔断{}",throwable.toString(),throwable);
                return null;
            }
        };
    }
}
